home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / proc / proc.h < prev    next >
C/C++ Source or Header  |  1991-05-30  |  13KB  |  323 lines

  1. /*
  2.  * proc.h --
  3.  *
  4.  *    External declarations of routines 
  5.  *    for managing processes.
  6.  *
  7.  * Copyright 1986, 1988 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  *
  17.  * rcsid $Header: /sprite/src/kernel/proc/RCS/proc.h,v 9.23 91/05/30 15:05:48 kupfer Exp $ SPRITE (Berkeley)
  18.  */
  19.  
  20. #ifndef _PROC
  21. #define _PROC
  22.  
  23. #ifdef KERNEL
  24. #include <procTypes.h>
  25. #include <user/sync.h>
  26. #include <syncLock.h>
  27. #include <list.h>
  28. #include <timer.h>
  29. #include <sig.h>
  30. #include <mach.h>
  31. #include <sysSysCallParam.h>
  32. #include <rpc.h>
  33. #else
  34. #include <kernel/procTypes.h>
  35. #include <sync.h>
  36. #include <kernel/syncLock.h>
  37. #include <list.h>
  38. #include <kernel/timer.h>
  39. #include <kernel/sig.h>
  40. #include <kernel/mach.h>
  41. #include <kernel/sysSysCallParam.h>
  42. #include <kernel/rpc.h>
  43. #endif /* */
  44.  
  45. /*
  46.  *  proc_RunningProcesses points to an array of pointers to
  47.  *  Proc_ControlBlock structures of processes currently running on each
  48.  *  CPU.  It is initialized by Proc_Init at boot time to the appropriate
  49.  *  size, which depends on the workstation configuration.
  50.  */
  51.  
  52. extern Proc_ControlBlock  **proc_RunningProcesses;
  53.  
  54.  
  55. /*
  56.  *  proc_PCBTable is the array of all valid PCB's in the system.
  57.  *  It is initialized by Proc_Init at boot time to the appropriate size,
  58.  *  which depends on the workstation configuration.
  59.  */
  60.  
  61. extern Proc_ControlBlock **proc_PCBTable;
  62.  
  63.  
  64. /*
  65.  *   Keep track of the maximum number of processes at any given time.
  66.  */
  67.  
  68. extern int proc_MaxNumProcesses;
  69.  
  70. /*
  71.  * set to TRUE to disallow all migrations to this machine.
  72.  */
  73. extern Boolean proc_RefuseMigrations;
  74.  
  75. /*
  76.  *  Macros to manipulate process IDs.
  77.  */
  78.  
  79. #define Proc_ComparePIDs(p1, p2) ((p1) == (p2))
  80.  
  81. #define Proc_GetPCB(pid) (proc_PCBTable[(pid) & PROC_INDEX_MASK])
  82.  
  83. #define Proc_ValidatePID(pid) \
  84.     ((((pid) & PROC_INDEX_MASK) < proc_MaxNumProcesses) && \
  85.      (((pid) == proc_PCBTable[(pid) & PROC_INDEX_MASK]->processID)))
  86.  
  87. #define PROC_GET_VALID_PCB(pid, procPtr) \
  88.     if (((pid) & PROC_INDEX_MASK) >= proc_MaxNumProcesses) { \
  89.     procPtr = (Proc_ControlBlock *) NIL; \
  90.     } else { \
  91.     procPtr = proc_PCBTable[(pid) & PROC_INDEX_MASK]; \
  92.     if ((pid) != (procPtr)->processID) { \
  93.         procPtr = (Proc_ControlBlock *) NIL; \
  94.     } \
  95.     }
  96.  
  97. #define    Proc_GetHostID(pid) (((pid) & PROC_ID_NUM_MASK) >> PROC_ID_NUM_SHIFT)
  98.  
  99. /*
  100.  * Macros to determine and set the "actual" currently running process.
  101.  */
  102.  
  103. #define    Proc_GetActualProc() \
  104.     proc_RunningProcesses[Mach_GetProcessorNumber()]
  105. #define Proc_SetActualProc(processPtr) \
  106.     proc_RunningProcesses[Mach_GetProcessorNumber()] = (processPtr)
  107.  
  108. #define Proc_GetCurrentProc() Proc_GetActualProc()
  109. #define Proc_SetCurrentProc(processPtr)    Proc_SetActualProc(processPtr)
  110.  
  111. /*
  112.  * Various routines use Proc_UseRpcBuffer to decide whether to copy 
  113.  * to/from user address space or kernel address space.  A common 
  114.  * example of using a kernel (RPC) buffer is when a migrated process 
  115.  * invokes a system call that is forwarded home.
  116.  * This macro bypasses Proc_GetEffectiveProc, since
  117.  * proc_RunningProcesses[processor] must be non-NIL.
  118.  */
  119.  
  120. #define    Proc_UseRpcBuffer() \
  121.     (proc_RunningProcesses[Mach_GetProcessorNumber()]->rpcClientProcess != \
  122.         ((Proc_ControlBlock *) NIL))
  123.  
  124. /*
  125.  * Used to get the lock at the top of the lock stack without popping it off.
  126.  */
  127. #define Proc_GetCurrentLock(pcbPtr, typePtr, lockPtrPtr) \
  128.     { \
  129.     if ((pcbPtr)->lockStackSize <= 0) { \
  130.         *(typePtr) = -1; \
  131.         *(lockPtrPtr) = (Address) NIL; \
  132.     } else { \
  133.         *(typePtr) = (pcbPtr)->lockStack[(pcbPtr)->lockStackSize-1].type; \
  134.         *(lockPtrPtr) = \
  135.         (pcbPtr)->lockStack[(pcbPtr)->lockStackSize-1].lockPtr; \
  136.     } \
  137.     }
  138. /* 
  139.  * External procedures.
  140.  */
  141.  
  142. extern ReturnStatus     Proc_ByteCopy _ARGS_((Boolean copyIn, int numBytes,
  143.                 Address sourcePtr, Address destPtr));
  144. extern void        Proc_CallFunc _ARGS_((void (*func)(
  145.                            ClientData clientData, 
  146.                            Proc_CallInfo *callInfoPtr), 
  147.                 ClientData clientData, unsigned int interval));
  148. extern ClientData     Proc_CallFuncAbsTime _ARGS_((void (*func)(
  149.                            ClientData clientData, 
  150.                            Proc_CallInfo *callInfoPtr), 
  151.                 ClientData clientData, Timer_Ticks time));
  152. extern void         Proc_CancelCallFunc _ARGS_((ClientData token));
  153. extern    ReturnStatus    Proc_Debug _ARGS_((Proc_PID pid, 
  154.                 Proc_DebugReq request, int numBytes,
  155.                 Address srcAddr, Address destAddr));
  156. extern    void        Proc_DestroyMigratedProc _ARGS_((ClientData pidData,
  157.                 Proc_CallInfo *callInfoPtr));
  158. extern ReturnStatus     Proc_Detach _ARGS_((int status));
  159. extern void         Proc_DetachInt _ARGS_((register 
  160.                 Proc_ControlBlock *procPtr));
  161. extern    ReturnStatus    Proc_DoForEveryProc _ARGS_((Boolean (*booleanFuncPtr)
  162.                         (Proc_ControlBlock *pcbPtr),
  163.                 ReturnStatus (*actionFuncPtr)(Proc_PID pid), 
  164.                 Boolean ignoreStatus, int *numMatchedPtr));
  165. extern ReturnStatus     Proc_DoRemoteCall _ARGS_((int callNumber, int numWords,
  166.                 ClientData *argsPtr, Sys_CallParam *specsPtr));
  167. extern    ReturnStatus    Proc_Dump _ARGS_((void));
  168. extern    void        Proc_DumpPCB _ARGS_((Proc_ControlBlock *procPtr));
  169. extern    ReturnStatus    Proc_EvictForeignProcs _ARGS_((void));
  170. extern    ReturnStatus    Proc_EvictProc _ARGS_((Proc_PID pid));
  171. extern    int        Proc_Exec _ARGS_((char *fileName, 
  172.                 char **argsPtrArray, char **envPtrArray,
  173.                 Boolean debugMe, int host));
  174. extern int         Proc_ExecEnv _ARGS_((char *fileName, 
  175.                 char **argPtrArray, char **envPtrArray, 
  176.                 Boolean debugMe));
  177. extern void         Proc_Exit _ARGS_((int status));
  178. extern void         Proc_ExitInt _ARGS_((int reason, int status, int code));
  179. extern    void        Proc_FlagMigration _ARGS_((Proc_ControlBlock *procPtr,
  180.                 int hostID, Boolean exec));
  181. extern    int        Proc_Fork _ARGS_((Boolean shareHeap, Proc_PID *pidPtr));
  182. extern    Proc_ControlBlock *Proc_GetEffectiveProc _ARGS_((void));
  183. extern    ReturnStatus    Proc_GetFamilyID _ARGS_((Proc_PID pid,
  184.                 Proc_PID *familyIDPtr));
  185. extern    ReturnStatus    Proc_GetGroupIDs _ARGS_((int numGIDs, int *gidArrayPtr,
  186.                 int *trueNumGIDsPtr));
  187. extern    ReturnStatus    Proc_GetHostIDs _ARGS_((int *virtualHostPtr, 
  188.                 int *physicalHostPtr));
  189. extern    ReturnStatus    Proc_GetIDs _ARGS_((Proc_PID *procIDPtr,
  190.                 Proc_PID *parentIDPtr, int *userIDPtr,
  191.                 int *effUserIDPtr));
  192. extern    ReturnStatus    Proc_GetIntervalTimer _ARGS_((int timerType,
  193.                 Proc_TimerInterval *userTimerPtr));
  194. extern    ReturnStatus    Proc_GetPCBInfo _ARGS_((Proc_PID firstPid,
  195.                 Proc_PID lastPid, int hostID, int infoSize,
  196.                 Address bufferPtr, Proc_PCBArgString *argsPtr,
  197.                 int *trueNumBuffersPtr));
  198. extern    ReturnStatus    Proc_GetPriority _ARGS_((Proc_PID pid, 
  199.                 int *priorityPtr));
  200. extern    ReturnStatus    Proc_GetRemoteSegInfo _ARGS_((int hostID, int segNum,
  201.                 Vm_SegmentInfo *segInfoPtr));
  202. extern    ReturnStatus    Proc_GetResUsage _ARGS_((Proc_PID pid, 
  203.                 Proc_ResUsage *bufferPtr));
  204. extern    Boolean        Proc_HasPermission _ARGS_((int userID));
  205. extern void         Proc_InformParent _ARGS_((register 
  206.                 Proc_ControlBlock *procPtr, int childStatus));
  207. extern void         Proc_Init _ARGS_((void));
  208. extern    void        Proc_InitMainEnviron _ARGS_((
  209.                 Proc_ControlBlock *procPtr));
  210. extern void         Proc_InitMainProc _ARGS_((void));
  211. extern    Boolean        Proc_IsEvictable _ARGS_((Proc_ControlBlock *procPtr));
  212. extern    int        Proc_KillAllProcesses _ARGS_((Boolean userProcsOnly));
  213. extern    void        Proc_KDump _ARGS_((ClientData dummy));
  214. extern    void        Proc_Lock _ARGS_((Proc_ControlBlock *procPtr));
  215. extern ReturnStatus     Proc_LockFamily _ARGS_((int familyID, 
  216.                 List_Links **familyListPtr, int *userIDPtr));
  217. extern    Proc_ControlBlock *Proc_LockPID _ARGS_((Proc_PID pid));
  218. extern ReturnStatus     Proc_MakeStringAccessible _ARGS_((int maxLength,
  219.                 char **stringPtrPtr, int *accessLengthPtr,
  220.                 int *newLengthPtr));
  221. extern void         Proc_MakeUnaccessible _ARGS_((Address addr, 
  222.                 int numBytes));
  223. extern    void        Proc_MigAddToCounter _ARGS_((int value, 
  224.                 unsigned int *intPtr, 
  225.                 unsigned int *squaredPtr));
  226. extern    ReturnStatus    Proc_MigGetStats _ARGS_((Address addr));
  227. extern    void        Proc_MigInit _ARGS_((void));
  228. extern    ReturnStatus    Proc_Migrate _ARGS_((Proc_PID pid, int hostID));
  229. extern    void        Proc_MigrateStartTracing _ARGS_((void));
  230. extern    void        Proc_MigrateTrap _ARGS_((Proc_ControlBlock *procPtr));
  231. extern    ReturnStatus    Proc_MigResetStats _ARGS_((void));
  232. extern ReturnStatus    Proc_MigUpdateInfo _ARGS_((Proc_ControlBlock *procPtr));
  233. extern    void        Proc_NeverMigrate _ARGS_((Proc_ControlBlock *procPtr));
  234. extern ReturnStatus    Proc_NewProc _ARGS_((Address PC, int procType,
  235.                 Boolean shareHeap, Proc_PID *pidPtr,
  236.                 char *procName));
  237. extern    void        Proc_NotifyMigratedWaiters _ARGS_((ClientData data,
  238.                 Proc_CallInfo *callInfoPtr));
  239. extern    ReturnStatus    Proc_Profile _ARGS_((int shiftSize, int lowPC,
  240.                 int highPC, Time interval, int counterArray[]));
  241. extern    void        Proc_PushLockStack _ARGS_((Proc_ControlBlock *pcbPtr,
  242.                 int type, Address lockPtr));
  243. extern void         Proc_Reaper _ARGS_((ClientData data,
  244.                 Proc_CallInfo *callInfoPtr));
  245. extern void        Proc_ResumeProcess _ARGS_((Proc_ControlBlock *procPtr,
  246.                 Boolean killingProc));
  247. extern    ReturnStatus    Proc_RemoteDummy _ARGS_((int callNumber, 
  248.                 int numWords, Sys_ArgArray *argsPtr,
  249.                 Sys_CallParam *specsPtr));
  250. extern int         Proc_RemoteExec _ARGS_((char *fileName, 
  251.                 char **argPtrArray,char **envPtrArray, 
  252.                 int host));
  253. extern    void        Proc_RemoveFromLockStack _ARGS_((
  254.                 Proc_ControlBlock *pcbPtr, Address lockPtr));
  255. extern    void        Proc_ResumeMigProc _ARGS_((int pc));
  256. extern    ReturnStatus    Proc_RpcGetPCB _ARGS_((ClientData srvToken,
  257.                 int clientID, int command,
  258.                 Rpc_Storage *storagePtr));
  259. extern    ReturnStatus    Proc_RpcMigCommand _ARGS_((ClientData srvToken,
  260.                 int hostID, int command, 
  261.                 Rpc_Storage *storagePtr));
  262. extern    ReturnStatus    Proc_RpcRemoteCall _ARGS_((ClientData srvToken,
  263.                 int clientID, int command, 
  264.                 Rpc_Storage *storagePtr));
  265. extern ReturnStatus     Proc_RpcRemoteWait _ARGS_((ClientData srvToken,
  266.                 int clientID, int command, 
  267.                 Rpc_Storage *storagePtr));
  268. extern void         Proc_UnlockFamily _ARGS_((int familyID));
  269. extern void         Proc_ServerInit _ARGS_((void));
  270. extern void         Proc_ServerProc _ARGS_((void));
  271. extern    void        Proc_SetEffectiveProc _ARGS_((
  272.                 Proc_ControlBlock *procPtr));
  273. extern    ReturnStatus    Proc_SetFamilyID _ARGS_((Proc_PID pid, 
  274.                 Proc_PID familyID));
  275. extern    ReturnStatus    Proc_SetGroupIDs _ARGS_((int numGIDs, 
  276.                 int *gidArrayPtr));
  277. extern    ReturnStatus    Proc_SetIDs _ARGS_((int userID, int effUserID));
  278. extern    ReturnStatus    Proc_SetIntervalTimer _ARGS_((int timerType,
  279.                 Proc_TimerInterval *newTimerPtr,
  280.                 Proc_TimerInterval *oldTimerPtr));
  281. extern    ReturnStatus    Proc_SetPriority _ARGS_((Proc_PID pid, int priority,
  282.                 Boolean useFamily));
  283. extern    void        Proc_SetServerPriority _ARGS_((Proc_PID pid));
  284. extern    void        Proc_SetupEnviron _ARGS_((Proc_ControlBlock *procPtr));
  285. extern    ReturnStatus    Proc_StringNCopy _ARGS_((int numBytes, char *srcStr,
  286.                 char *destStr, int *strLengthPtr));
  287. extern    void        Proc_SuspendProcess _ARGS_((
  288.                 Proc_ControlBlock *procPtr, Boolean debug,
  289.                 int termReason, int termStatus, 
  290.                 int termCode));
  291. extern    void        Proc_Unlock _ARGS_((Proc_ControlBlock *procPtr));
  292. extern    ReturnStatus    Proc_Wait _ARGS_((int numPids, Proc_PID pidArray[],
  293.                 int flags, Proc_PID *procIDPtr, 
  294.                 int *reasonPtr, int *statusPtr, 
  295.                 int *subStatusPtr, Proc_ResUsage *usagePtr));
  296. extern    ReturnStatus    Proc_WaitForHost _ARGS_((int hostID));
  297. extern    ReturnStatus    Proc_WaitForMigration _ARGS_((Proc_PID processID));
  298. extern    void        Proc_WakeupAllProcesses _ARGS_((void));
  299. extern    int        proc_NumServers;
  300. /*
  301.  * The following are kernel stubs corresponding to system calls.  They
  302.  * used to be known by the same name as the system call, but the C library
  303.  * has replaced them at user level in order to use the stack environments.
  304.  * The "Stub" suffix therefore avoids naming conflicts with the library.
  305.  */
  306.  
  307. extern    ReturnStatus    Proc_SetEnvironStub _ARGS_((
  308.                 Proc_EnvironVar environVar));
  309. extern    ReturnStatus    Proc_UnsetEnvironStub _ARGS_((
  310.                 Proc_EnvironVar environVar));
  311. extern    ReturnStatus    Proc_GetEnvironVarStub _ARGS_((
  312.                 Proc_EnvironVar environVar));
  313. extern    ReturnStatus    Proc_GetEnvironRangeStub _ARGS_((int first, int last,
  314.                 Proc_EnvironVar *envArray, 
  315.                 int *numActualVarsPtr));
  316. extern    ReturnStatus    Proc_CopyEnvironStub _ARGS_((void));
  317. extern    ReturnStatus    Proc_InstallEnvironRangeStub _ARGS_((
  318.                 Proc_EnvironVar environVar, int numVars));
  319. extern     int         Proc_KernExec _ARGS_((char *fileName, 
  320.                 char **argPtrArray));
  321.  
  322. #endif /* _PROC */
  323.